<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        body {
            padding: 0px;
            margin: 0px;
        }
        ul {
            list-style: none;
        }
        ul li {
            display: inline;
            float: left;
            margin-left: 15px;
        }
        ul li:hover {
            background: white;
            color: #00BFFF;
        }

    </style>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id="app-32">
        <router-link to="/login">登录</router-link><br />
        <router-link to="/alias-login">(别名)-登录</router-link> <br />
        <router-link to="/index">首页</router-link>
        <router-view></router-view>
    </div>

    <script type="text/javascript">
        <!-- vue 的路由旨在为单页面应用开发提供便携 -->
        // 1. 定义链接跳转的模板（组件）
        const t1 = {
            template: `<div style="width: 400px; height: 200px; border: blue 1px solid" >
                    登录
                    </div>`
        };
        // 2. 定义路由
        const my_router = new VueRouter({
           routes: [
               {
                   path: '/login',
                   name: "r1",
                   alias: "/alias-login",
                   component: t1
               },
               {
                   path: '/index',
                   // 根据路由路径重定向
                   // redirect: "/login"
                   // 根据路由命名重定向
                   redirect: {name: "r1"}
               }
           ]
        });
        // 3. 引用路由
        var vm = new Vue({
           el: '#app-32',
            router: my_router
        });
    </script>

</body>
</html>